package com.demo.gallery3d;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Toast;

import com.example.myalldemo.R;

/**
 * http://android.tgbus.com/Android/tutorial/201108/362438.shtml
 * 在BaseAdapter中主要做了图片的倒影效果以及创建了对原始图片和倒影的显示区域
 * 。GalleryFlow中主要做了对图片的旋转和缩放操作，根据图片的屏幕中的位置对其进行旋转缩放操作。
 * 
 */
public class MainGallery3DActivity extends Activity {
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.gallery_main);

		Integer[] images = { R.drawable.img1, R.drawable.img2, R.drawable.img3,
				R.drawable.img4, R.drawable.img5, R.drawable.img6,
				R.drawable.img6, R.drawable.img7 };

		ImageAdapter adapter = new ImageAdapter(this, images);
		adapter.createReflectedImages();// 创建倒影效果
		GalleryFlow galleryFlow = (GalleryFlow) this
				.findViewById(R.id.Gallery01);
		galleryFlow.setFadingEdgeLength(0);
		galleryFlow.setSpacing(-100); // 图片之间的间距
		galleryFlow.setAdapter(adapter);

		galleryFlow.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Toast.makeText(getApplicationContext(),
						String.valueOf(position), Toast.LENGTH_SHORT).show();
			}

		});
		galleryFlow.setSelection(4);
	}

}
